<?php
/*
  $Id Tgely http://oscom.hu v1.0$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2010 osCommerce

*/

  require('includes/application_top.php');

//  define('TABLE_MENU', 'menu');
//  define('TABLE_MENU_TEXT', 'menu_text');
//  define('FILENAME_MENU_MAKER', 'menu_maker.php');
  

  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

  $error = false;
  $processed = false;

  if (tep_not_null($action)) {
    switch ($action) {
      case 'update':

        $xID = (int)tep_db_prepare_input($HTTP_GET_VARS['menuID']);
        $x = tep_db_prepare_input($HTTP_POST_VARS['show_condition']);  //0 or 1
        $x1 = tep_db_prepare_input($HTTP_POST_VARS['class']);
        $x2 = tep_db_prepare_input($HTTP_POST_VARS['link']); 
        $x3 = tep_db_prepare_input($HTTP_POST_VARS['link_param']); //only exist id
        $x4 = tep_db_prepare_input($HTTP_POST_VARS['parent']); //only exist menu_id and not self
        $x5 = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);

        //arrays
        $y1 = tep_db_prepare_input($HTTP_POST_VARS['lang_text']);
        $y2 = tep_db_prepare_input($HTTP_POST_VARS['menu_text_id']);
        

//        if ($error == false) {

          $sql_data_array = array('show_condition' => $x,
                                  'class' => $x1,
                                  'link' => $x2,
                                  'link_param' => $x3,
                                  'parent' => $x4,
                                  'sort_order' => $x5);

          $kontroll = tep_db_perform(TABLE_MENU, $sql_data_array, 'update', "menu_id = '" . $xID . "'");

          if ($kontroll) {
            $messageStack->add_session(ACTION_UPDATE_MENU_CONTROLL_SUCCESS, 'success');
          } else {
            $messageStack->add_session(ACTION_UPDATE_MENU_CONTROLL_ERROR, 'error');
          }

          $languages = tep_get_languages();
          for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

            $sql_data_array = array('text' => $y1[$languages[$i]['id']],
                                    'language_id' => $languages[$i]['id']);
            
            $kontroll = tep_db_perform(TABLE_MENU_TEXT, $sql_data_array, 'update', "menu_text_id = '" . $y2[$languages[$i]['id']] . "'");
            if ($kontroll) {
              $messageStack->add_session(ACTION_UPDATE_MENU_TEXT_CONTROLL_SUCCESS . ' ' . $languages[$i]['name'], 'success');
            } else {
              $messageStack->add_session(ACTION_UPDATE_MENU_TEXT_CONTROLL_ERROR . ' ' . $languages[$i]['name'], 'error');
            }

          }

          if (USE_CACHE == 'true') {
            tep_reset_cache_block('menu_module');
          }
        
          tep_redirect(tep_href_link(FILENAME_MENU_MAKER, tep_get_all_get_params(array('action')) . (isset($_GET['page']) ? 'page=' . $_GET['page'] : "")));

/*        } else if ($error == true) {
          $xInfo = new objectInfo($HTTP_POST_VARS);
          $processed = true;
        } */

        break;
      case 'create':
           $kontroll = false;
           $sql_data_array = array('show_condition' => 1,
                                  'class' => '',
                                  'link' => '',
                                  'link_param' => '',
                                  'parent' => 0,
                                  'sort_order' => NULL);

          $kontroll = tep_db_perform(TABLE_MENU, $sql_data_array, 'insert');
          $menu_id = tep_db_insert_id();
          
          $languages = tep_get_languages();
          for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

            $sql_data_array = array('text' => '',
                                    'language_id' => $languages[$i]['id'],
                                    'menu_id' => $menu_id);
            
            $kontroll = tep_db_perform(TABLE_MENU_TEXT, $sql_data_array, 'insert');
            if ($kontroll) {
              $messageStack->add_session(ACTION_UPDATE_MENU_TEXT_CONTROLL_SUCCESS . ' ' . $languages[$i]['name'], 'success');
            } else {
              $messageStack->add_session(ACTION_UPDATE_MENU_TEXT_CONTROLL_ERROR . ' ' . $languages[$i]['name'], 'error');
            }

          }
          
          if (USE_CACHE == 'true') {
            tep_reset_cache_block('menu_module');
          }
        
        tep_redirect(tep_href_link(FILENAME_MENU_MAKER, tep_get_all_get_params(array('menuID', 'action')) . 'menuID=' . $menu_id . '&action=edit'));
        break;
      case 'deleteconfirm':
        $menuID = tep_db_prepare_input($HTTP_GET_VARS['menuID']);

        if (isset($HTTP_GET_VARS['delete_menu_table']) && ($HTTP_GET_VARS['delete_menu_table'] == 'on')) {
          tep_db_query("delete from " . TABLE_MENU . " where menu_id = '" . $menuID . "'");
          tep_db_query("delete from " . TABLE_MENU_TEXT . " where menu_id = '" . $menuID . "'");

          if (USE_CACHE == 'true') {
            tep_reset_cache_block('menu_module');
          }
        }

        tep_redirect(tep_href_link(FILENAME_MENU_MAKER, tep_get_all_get_params(array('menuID', 'action', 'delete_menu_table'))));
        break;
      default:
        $menu_query = tep_db_query("select x.*, y.text, y.menu_text_id from " . TABLE_MENU . " x left join " . TABLE_MENU_TEXT . " y on x.menu_id = y.menu_id where y.language_id = '" . $languages_id . "' and x.menu_id = '" . $HTTP_GET_VARS['menuID'] . "'");
        $x_var = tep_db_fetch_array($menu_query);

        $xInfo = new objectInfo($x_var);
    }
  }
  
  function build_menu($sectionid) {
    global $languages_id;
     
    $get_data = tep_db_query("select x.*, y.text, y.menu_text_id from " . TABLE_MENU . " x left join " . TABLE_MENU_TEXT . " y on x.menu_id = y.menu_id where y.language_id = '" . $languages_id . "' and x.parent = '" . $sectionid . "' and show_condition = '0' ORDER BY x.parent, x.sort_order ASC");
   
    while ($menu_list = tep_db_fetch_array($get_data)) {
      $getsubsections[] = array('id'             => $menu_list['menu_id'],
                                'text'           => $menu_list['text'],
                                'class'          => $menu_list['class'],
                                'link'           => $menu_list['link'],
                                'link_param'     => $menu_list['link_param']);
    }
    
    if (isset($getsubsections) && tep_not_null($getsubsections)) {
      echo '<ul>' . PHP_EOL;
      foreach($getsubsections as $key => $subsection) {
        echo '<li class="' . $subsection['class'] . '"><a href="' . tep_catalog_href_link($subsection['link'], $subsection['link_param']) . '">' . $subsection['text'] . '</a>' . PHP_EOL;
        $subcont = build_menu($subsection['id']);
        echo '</li>' . PHP_EOL;
      }
      echo '</ul>' . PHP_EOL;
    }
    
    return;
  }
  
  require(DIR_WS_INCLUDES . 'template_top.php');

  if ($action == 'edit' || $action == 'update') {

    $languages = tep_get_languages();

?>
<script type="text/javascript"><!--

function check_form() {
  var error = 0;
  var error_message = "<?php echo JS_ERROR; ?>";

<?php
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
  if (document.menu_maker.elements["lang_text[<?php echo $languages[$i]['id'] ?>]"].value < 1) {
    error_message = error_message + "<?php echo TEXT_TEXT_ERROR; ?>";
    error = 1;
  }

<?php
}
?>
  var link = document.menu_maker.link.value;

  if (link < 1) {
    error_message = error_message + "<?php echo TEXT_LINK_ERROR; ?>";
    error = 1;
  }

  var liclass = document.menu_maker.class.value;
  
  if (liclass < 1) {
    error_message = error_message + "<?php echo TEXT_CLASS_ERROR; ?>";
    error = 1;
  }
  
  if (error == 1) {
    alert(error_message);
    return false;
  } else {
    return true;
  }
}
//--></script>
<?php
  }
?>

    <table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
  if ($action == 'edit' || $action == 'update') {
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr><?php echo tep_draw_form('menu_maker', FILENAME_MENU_MAKER, tep_get_all_get_params(array('action')) . 'action=update', 'post', 'onsubmit="return check_form();"') . tep_draw_hidden_field('menu_id', $xInfo->menu_id); ?>
        <td class="formAreaTitle"><?php echo TEXT_EDIT_GOUP_TITLE; ?></td>
      </tr>
      <tr>
        <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td class="main"><?php echo TEXT_CLASS; ?></td>
            <td class="main">
<?php
  if ($error == true) {
    if ($entry_class_error == true) {
      echo tep_draw_input_field('class', $xInfo->class, 'maxlength="32"') . '&nbsp;' . ENTRY_CLASS_ERROR;
    } else {
      echo $xInfo->class . tep_draw_hidden_field('class');
    }
  } else {
    echo tep_draw_input_field('class', $xInfo->class, 'maxlength="32"', true);
  }
?></td>
          </tr>
          <tr>
            <td class="main"><?php echo TEXT_LINK; ?></td>
            <td class="main">
<?php
  if ($error == true) {
    if ($entry_link_error == true) {
      echo tep_draw_input_field('link', $xInfo->link, 'maxlength="32"') . '&nbsp;' . ENTRY_LINK_ERROR;
    } else {
      echo $xInfo->link . tep_draw_hidden_field('link');
    }
  } else {
    echo tep_draw_input_field('link', $xInfo->link, 'maxlength="32"', true);
  }
?></td>
          </tr>
          <tr>
            <td class="main"><?php echo TEXT_LINK_PARAM; ?></td>
            <td class="main">
<?php
  if ($error == true) {
    if ($entry_link_param_error == true) {
      echo tep_draw_input_field('link_param', $xInfo->link_param, 'maxlength="32"') . '&nbsp;' . ENTRY_LINK_PARAM_ERROR;
    } else {
      echo $xInfo->link_param . tep_draw_hidden_field('link_param');
    }
  } else {
    echo tep_draw_input_field('link_param', $xInfo->link_param, 'maxlength="32"');
  }
?></td>
          </tr>
          <tr>
            <td class="main"><?php echo TEXT_SHOW_CONDITION; ?></td>
            <td class="main">
<?php
  if ($error == true) {
    if ($entry_show_condition_error == true) {
      echo tep_draw_radio_field('show_condition', 0, false, $xInfo->show_condition) . '&nbsp;&nbsp;' . SHOW . '&nbsp;&nbsp;' . tep_draw_radio_field('show_condition', 1, false, $xInfo->show_condition) . '&nbsp;&nbsp;' . HIDE . '&nbsp;' . ENTRY_SHOW_CONDITION_ERROR;
    } else {
      echo ($xInfo->show_condition == 0) ? SHOW : HIDE;
      echo tep_draw_hidden_field('show_condition');
    }
  } else {
    echo tep_draw_radio_field('show_condition', 0, false, $xInfo->show_condition) . '&nbsp;&nbsp;' . SHOW . '&nbsp;&nbsp;' . tep_draw_radio_field('show_condition', 1, false, $xInfo->show_condition) . '&nbsp;&nbsp;' . HIDE;
  }
?></td>
          </tr>
          <tr>
            <td class="main"><?php echo TEXT_PARENT; ?></td>
            <td class="main">
<?php
  if ($error == true) {
    if ($entry_parent_error == true) {
      echo tep_draw_input_field('parent', $xInfo->parent, 'maxlength="32"') . '&nbsp;' . ENTRY_PARENT_ERROR;
    } else {
      echo $xInfo->parent . tep_draw_hidden_field('parent');
    }
  } else {
    echo tep_draw_input_field('parent', $xInfo->parent, 'maxlength="32"');
  }
?></td>
          </tr>
          <tr>
            <td class="main"><?php echo TEXT_SORT_ORDER; ?></td>
            <td class="main">
<?php
  if ($error == true) {
    if ($entry_sort_order_error == true) {
      echo tep_draw_input_field('sort_order', $xInfo->sort_order, 'maxlength="32"') . '&nbsp;' . ENTRY_SORT_ORDER_ERROR;
    } else {
      echo $xInfo->sort_order . tep_draw_hidden_field('sort_order');
    }
  } else {
    echo tep_draw_input_field('sort_order', $xInfo->sort_order, 'maxlength="32"');
  }
?></td>
          </tr>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td>
<script>
	$(function() {
		$( "#tabs" ).tabs();
	});
</script>

<div class="demo">

<div id="tabs">
<?php

    $li_text = '<ul>';
    $div_text = '';

    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
      $menu_text_query = tep_db_query("select * from " . TABLE_MENU_TEXT . " where menu_id = '" . (int)$HTTP_GET_VARS['menuID'] . "' and language_id = '" . $languages[$i]['id'] . "'");
      $lang_var = tep_db_fetch_array($menu_text_query);
      

      $li_text .= '<li><a href="#tabs-' . $i . '">' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . $lang_var['text'] . '</a></li>' . PHP_EOL;

      $div_text .= '<div id="tabs-' . $i . '">' . TEXT_TEXT . '&nbsp;:&nbsp;' . tep_draw_hidden_field('menu_text_id[' . $lang_var['language_id'] . ']', $lang_var['menu_text_id']);

      if ($error == true) {
        if ($entry_text_error == true) {
          $div_text .= tep_draw_input_field('lang_text[' . $lang_var['language_id'] . ']', $lang_var['text'], 'maxlength="32"') . '&nbsp;' . ENTRY_TEXT_ERROR;
        } else {
          $div_text .= $lang_var['text'] . tep_draw_hidden_field('lang_text[' . $lang_var['language_id'] . ']');
          
        }
      } else {
        $div_text .= tep_draw_input_field('lang_text[' . $lang_var['language_id'] . ']', $lang_var['text'], 'maxlength="32"', true);
      }
      $div_text .=  '</div>' . PHP_EOL;
    }
    
    $li_text .= '</ul>';

    echo $li_text;
    echo $div_text;
    
?>
  </div>
</div><!-- End tabs -->
        </td>
      </tr>
      

      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td align="right" class="smallText"><?php echo tep_draw_button(IMAGE_SAVE, 'disk', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_MENU_MAKER, tep_get_all_get_params(array('action')))); ?></td>
      </tr></form>
      </tr>
<?php
  } else {
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr><?php echo tep_draw_form('search', FILENAME_MENU_MAKER, '', 'get'); ?>
            <td class="pageHeading"><?php echo HEADING_TITLE_YYY; ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
            <td class="smallText" align="right"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search'); ?></td>
          <?php echo tep_hide_session_id(); ?></form></tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_1; ?></td>
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_2; ?></td>
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_3; ?></td>
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_4; ?></td>
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_5; ?></td>
                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_6; ?></td>
                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              </tr>
<?php
    $search = '';
    if (isset($HTTP_GET_VARS['search']) && tep_not_null($HTTP_GET_VARS['search'])) {
      $keywords = tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['search']));
      $search = " and (x.class like '%" . $keywords . "%' or text like '%" . $keywords . "%')";
    }

    $menu_query_raw = "select x.*, y.text from " . TABLE_MENU . " x left join " . TABLE_MENU_TEXT . " y on x.menu_id = y.menu_id where y.language_id = '" . $languages_id . "'" . $search . "";


    $menu_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $menu_query_raw, $menu_query_numrows);
    $menu_query = tep_db_query($menu_query_raw);
        
    while ($menu = tep_db_fetch_array($menu_query)) {
      $info_query = tep_db_query("select * from " . TABLE_MENU . " where menu_id = '" . $menu['menu_id'] . "'");
      $info = tep_db_fetch_array($info_query);

      if ((!isset($HTTP_GET_VARS['menuID']) || (isset($HTTP_GET_VARS['menuID']) && ($HTTP_GET_VARS['menuID'] == $menu['menu_id']))) && !isset($xInfo)) {
      
        $xInfo_array = array_merge($menu);
        $xInfo = new objectInfo($xInfo_array);
      }

      if (isset($xInfo) && is_object($xInfo) && ($menu['menu_id'] == $xInfo->menu_id)) {
        echo '          <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MENU_MAKER, tep_get_all_get_params(array('menuID', 'action')) . 'menuID=' . $xInfo->menu_id . '&action=edit') . '\'">' . "\n";
      } else {
        echo '          <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MENU_MAKER, tep_get_all_get_params(array('menuID')) . 'menuID=' . $menu['menu_id']) . '\'">' . "\n";
      }
?>
                <td class="dataTableContent"><?php echo $menu['menu_id']; ?></td>
                <td class="dataTableContent"><?php 

      if ($menu['show_condition'] == 0) {
        echo tep_image(DIR_WS_IMAGES . 'icons/tick.gif', IMAGE_ICON_STATUS_OK, 10, 10);
      } else {
        echo tep_image(DIR_WS_IMAGES . 'icons/cross.gif', IMAGE_ICON_STATUS_ERROR, 10, 10);
      }

 ?></td>
                <td class="dataTableContent"><?php echo $menu['class']; ?></td>
  
                <td class="dataTableContent" align="left"><?php echo (($menu['parent'] > 0) ? '<span style="color:red">'. $menu['text'] . '</span>' : $menu['text']); ?>&nbsp;</td>
                <td class="dataTableContent" align="right"><?php echo $menu['parent']; ?>&nbsp;</td>
                <td class="dataTableContent" align="right"><?php echo $menu['sort_order']; ?>&nbsp;</td>
                <td class="dataTableContent" align="right"><?php if (isset($xInfo) && is_object($xInfo) && ($menu['menu_id'] == $xInfo->menu_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_MENU_MAKER, tep_get_all_get_params(array('menuID')) . 'menuID=' . $menu['menu_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
              </tr>
<?php
    }
?>
              <tr>
                <td colspan="7"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText" valign="top"><?php echo $menu_split->display_count($menu_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_MENUS); ?></td>
                    <td class="smallText" align="right"><?php echo $menu_split->display_links($menu_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'menuID'))); ?></td>
                  </tr>
<?php
    if (isset($HTTP_GET_VARS['search']) && tep_not_null($HTTP_GET_VARS['search'])) {
?>
                  <tr>
                    <td class="smallText" align="right" colspan="2"><?php echo tep_draw_button(IMAGE_RESET, 'arrowrefresh-1-w', tep_href_link(FILENAME_MENU_MAKER)); ?></td>
                  </tr>
<?php
    }
?>
                </table></td>
              </tr>
            </table></td>
<?php
  $heading = array();
  $contents = array();

  switch ($action) {
    case 'confirm':
      $heading[] = array('text' => '<strong>' . TEXT_INFO_HEADING_DELETE_MENU . '</strong>');

      $contents = array('form' => tep_draw_form('menu', FILENAME_MENU_MAKER, tep_get_all_get_params(array('menuID', 'action')) . 'menuID=' . $xInfo->menu_id . '&action=deleteconfirm&delete_menu_table=on'));
      $contents[] = array('text' => TEXT_DELETE_INTRO . '<br /><br /><strong>' . $xInfo->class . ' ' . $xInfo->text . '</strong>');
      $contents[] = array('text' => '<br /><strong>' . $xInfo->text . '</strong>');
      $contents[] = array('align' => 'center', 'text' => '<br />' . tep_draw_button(IMAGE_DELETE, 'trash', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_MENU_MAKER, 'page=' . $HTTP_GET_VARS['page'] . '&menuID=' . $xInfo->menu_id)));

      break;
    default:
      if (isset($xInfo) && is_object($xInfo)) {
        $heading[] = array('text' => '<strong>' . $xInfo->text . ' ' . $xInfo->class . '</strong>');

        $contents[] = array('align' => 'center', 'text' => tep_draw_button(IMAGE_EDIT, 'document', tep_href_link(FILENAME_MENU_MAKER, tep_get_all_get_params(array('menuID', 'action')) . 'menuID=' . $xInfo->menu_id . '&action=edit')) . tep_draw_button(IMAGE_DELETE, 'trash', tep_href_link(FILENAME_MENU_MAKER, tep_get_all_get_params(array('menuID', 'action')) . 'menuID=' . $xInfo->menu_id . '&action=confirm')) . tep_draw_button(IMAGE_NEW_MENU, 'circle-plus', tep_href_link(FILENAME_MENU_MAKER, 'action=create')));
        
        $contents[] = array('text' => '<table>');
        $contents[] = array('text' => '<tr><td>' . TEXT_LINK . '</td><td align="right">' . $xInfo->link . '</td></tr>');
        $contents[] = array('text' => '<tr><td>' . TEXT_LINK_PARAM . '</td><td align="right">' . $xInfo->link_param . '</td></tr>');
        $contents[] = array('text' => '<tr><td>' . TEXT_PARENT . '</td><td align="right">'  . $xInfo->parent . '</td></tr>');
        $contents[] = array('text' => '</table>');
        
      } else {
        //start insert data button
        $heading[] = array('text' => '<strong>' . FIRST_PAGE . '</strong>');
        $contents[] = array('align' => 'center', 'text' => tep_draw_button(IMAGE_NEW_MENU, 'circle-plus', tep_href_link(FILENAME_MENU_MAKER, 'action=create')));
      }
      break;
  }

  if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
    echo '            <td width="25%" valign="top">' . "\n";

    $box = new box;
    echo $box->infoBox($heading, $contents);

    echo '            </td>' . "\n";
  }
?>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td>
<?php build_menu(0); ?>
        </td>
      </tr>
<?php
  }
?>
    </table>

<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>